<Page x:Class="RRX.Xml.ProjectTree.PageProjectTree"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:dd="clr-namespace:RRX.DragDrop;assembly=RRX.DragDrop" 
      xmlns:local="clr-namespace:RRX.Xml.ProjectTree"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      Title="ProjectTree">

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <!-- LINKS -->
     
        <Grid Grid.Column="0" Margin="5">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <Label Content="Templates" Grid.Row="0"/>
            <TreeView x:Name="Templates" Grid.Row="1" VerticalAlignment="Stretch" 
            dd:DragDrop.DropTargetAdornerBrush="Red" dd:DragDrop.UseDefaultDragAdorner="False"  dd:DragDrop.UseVisualSourceItemSizeForDragAdorner="False"   dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="False" dd:DragDrop.DropHandler="{Binding}" dd:DragDrop.DropScrollingMode="VerticalOnly"
            Loaded="Tree_Loaded" RequestBringIntoView="Tree_RequestBringIntoView" >
            </TreeView>
        </Grid>


        <!-- MITTE -->
        <Grid Grid.Column="2" Margin="5">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <Label Content="Tree" Grid.Row="0"/>
            <TreeView x:Name="Xml" Grid.Row="1" VerticalAlignment="Stretch" 
            dd:DragDrop.DropTargetAdornerBrush="Red" dd:DragDrop.UseDefaultDragAdorner="False"  dd:DragDrop.UseVisualSourceItemSizeForDragAdorner="False"   dd:DragDrop.IsDragSource="False" dd:DragDrop.IsDropTarget="True" dd:DragDrop.DropHandler="{Binding}" dd:DragDrop.DropScrollingMode="VerticalOnly"
            Loaded="Tree_Loaded" RequestBringIntoView="Tree_RequestBringIntoView" >
            </TreeView>
        </Grid>

        <!-- BUTTON -->
        <Button Grid.Column="3" Content="→" Margin="5" VerticalAlignment="Center" Click="Button_Click"/>


        <Grid Grid.Column="4" Margin="5">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <Label Content="Output" Grid.Row="0"/>
            <TextBox x:Name="TextBox" Grid.Row="1" AcceptsReturn="True" VerticalAlignment="Stretch"/>
        </Grid>

    </Grid>

    <Page.Resources>

        <!-- ItemProjectTreeXml -->
        <HierarchicalDataTemplate DataType="{x:Type local:ItemProjectTreeXml}" ItemsSource="{Binding Children}" >

            <StackPanel Orientation="Horizontal" Background="Transparent" Margin="1" Height="16" >
                <Label x:Name="ItemName" Margin="5,0,0,0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Content="{Binding Path=Name}"/>
            </StackPanel>

        </HierarchicalDataTemplate>

        <!-- ItemProjectTreeProject -->
        <HierarchicalDataTemplate DataType="{x:Type local:ItemProjectTreeProject}" ItemsSource="{Binding Children}" >

            <StackPanel Orientation="Horizontal" Background="Transparent" Margin="1" Height="16" >
                <Path x:Name="Icon" Stroke="Transparent" Fill="#FF808080" Height="14" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center"  VerticalAlignment="Center"  Data="M36.5,6h-25C8.468,6,6,8.467,6,11.5v25c0,3.033,2.468,5.5,5.5,5.5h25c3.032,0,5.5-2.467,5.5-5.5v-25	C42,8.467,39.532,6,36.5,6z M36.5,39h-25C10.121,39,9,37.878,9,36.5V16h30v20.5C39,37.878,37.879,39,36.5,39z" />
                <TextBox x:Name="ItemName" Margin="5,0,0,0" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Text="{Binding Path=Name}"/>
            </StackPanel>

        </HierarchicalDataTemplate>

        <!-- ItemProjectTreeAsp -->
        <HierarchicalDataTemplate DataType="{x:Type local:ItemProjectTreeAsp}" ItemsSource="{Binding Children}" >

            <StackPanel Orientation="Horizontal" Background="Transparent" Margin="1" Height="16" >
                <Path x:Name="Icon" Stroke="Transparent" Fill="#FF808080" Height="14" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center"  VerticalAlignment="Center"  Data="M6,38.5C6,40.43,7.57,42,9.5,42h29c1.93,0,3.5-1.57,3.5-3.5V32H6V38.5z M6,29h36V19H6V29z M38.5,6h-29C7.57,6,6,7.57,6,9.5 V16h36V9.5C42,7.57,40.43,6,38.5,6z M37,11c0,1.105-0.895,2-2,2s-2-0.895-2-2s0.895-2,2-2S37,9.895,37,11z M21.5,12.5h-9 c-0.828,0-1.5-0.671-1.5-1.5s0.672-1.5,1.5-1.5h9c0.828,0,1.5,0.671,1.5,1.5S22.328,12.5,21.5,12.5z M37,24c0,1.105-0.895,2-2,2 s-2-0.895-2-2s0.895-2,2-2S37,22.895,37,24z M21.5,25.5h-9c-0.828,0-1.5-0.671-1.5-1.5s0.672-1.5,1.5-1.5h9 c0.828,0,1.5,0.671,1.5,1.5S22.328,25.5,21.5,25.5z M37,37c0,1.105-0.895,2-2,2s-2-0.895-2-2s0.895-2,2-2S37,35.895,37,37z M21.5,38.5h-9c-0.828,0-1.5-0.671-1.5-1.5s0.672-1.5,1.5-1.5h9c0.828,0,1.5,0.671,1.5,1.5S22.328,38.5,21.5,38.5z" />
                <TextBox x:Name="ItemName" Margin="5,0,0,0" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Text="{Binding Path=Name}"/>
            </StackPanel>

        </HierarchicalDataTemplate>

        <!-- ItemProjectTreeSystem -->
        <HierarchicalDataTemplate DataType="{x:Type local:ItemProjectTreeSystem}" ItemsSource="{Binding Children}" >

            <StackPanel Orientation="Horizontal" Background="Transparent" Margin="1" Height="16" >
                <Path x:Name="Icon" Stroke="Transparent" Fill="#FF808080" Height="14" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center"  VerticalAlignment="Center"  Data="M 8.5 8 C 6.019 8 4 10.019 4 12.5 L 4 18 L 16.052734 18 C 16.636734 18 17.202344 17.793922 17.652344 17.419922 L 23.5 12.546875 L 19.572266 9.2734375 C 18.586266 8.4524375 17.336734 8 16.052734 8 L 8.5 8 z M 27.644531 13 L 19.572266 19.724609 C 18.585266 20.546609 17.336734 21 16.052734 21 L 4 21 L 4 35.5 C 4 37.981 6.019 40 8.5 40 L 39.5 40 C 41.981 40 44 37.981 44 35.5 L 44 17.5 C 44 15.019 41.981 13 39.5 13 L 27.644531 13 z" />
                <TextBox x:Name="ItemName" Margin="5,0,0,0" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Text="{Binding Path=Name}"/>
            </StackPanel>

        </HierarchicalDataTemplate>

        <!-- ItemProjectTreePage -->
        <HierarchicalDataTemplate DataType="{x:Type local:ItemProjectTreePage}" ItemsSource="{Binding Children}" >

            <StackPanel Orientation="Horizontal" Background="Transparent" Margin="1" Height="16" >
                <Path x:Name="Icon" Stroke="Transparent" Fill="#FF808080" Height="14" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center"  VerticalAlignment="Center"  Data="M 10.5 6 C 8.0324991 6 6 8.0324991 6 10.5 L 6 37.5 C 6 39.967501 8.0324991 42 10.5 42 L 28 42 L 28 32.5 C 28 29.996501 29.996501 28 32.5 28 L 42 28 L 42 10.5 C 42 8.0324991 39.967501 6 37.5 6 L 10.5 6 z M 33 31 C 31.895 31 31 31.895 31 33 L 31 41.119141 L 41.119141 31 L 33 31 z" />
                <TextBox x:Name="ItemName" Margin="5,0,0,0" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Text="{Binding Path=Name}"/>
            </StackPanel>

        </HierarchicalDataTemplate>

        <!-- ItemProjectTreePageHeizkreis -->
        <HierarchicalDataTemplate DataType="{x:Type local:ItemProjectTreePageHeizkreis}" ItemsSource="{Binding Children}" >

            <StackPanel Orientation="Horizontal" Background="Transparent" Margin="1" Height="16" >
                <Path x:Name="Icon" Stroke="Transparent" Fill="#FF808080" Height="14" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center"  VerticalAlignment="Center"  Data="M 10.5 6 C 8.0324991 6 6 8.0324991 6 10.5 L 6 37.5 C 6 39.967501 8.0324991 42 10.5 42 L 28 42 L 28 32.5 C 28 29.996501 29.996501 28 32.5 28 L 42 28 L 42 10.5 C 42 8.0324991 39.967501 6 37.5 6 L 10.5 6 z M 33 31 C 31.895 31 31 31.895 31 33 L 31 41.119141 L 41.119141 31 L 33 31 z" />
                <TextBox x:Name="ItemName" Margin="5,0,0,0" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Text="{Binding Path=Name}"/>
            </StackPanel>

        </HierarchicalDataTemplate>

        <!-- ItemProjectTreePageLüftung -->
        <HierarchicalDataTemplate DataType="{x:Type local:ItemProjectTreePageLüftung}" ItemsSource="{Binding Children}" >

            <StackPanel Orientation="Horizontal" Background="Transparent" Margin="1" Height="16" >
                <Path x:Name="Icon" Stroke="Transparent" Fill="#FF808080" Height="14" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center"  VerticalAlignment="Center"  Data="M 10.5 6 C 8.0324991 6 6 8.0324991 6 10.5 L 6 37.5 C 6 39.967501 8.0324991 42 10.5 42 L 28 42 L 28 32.5 C 28 29.996501 29.996501 28 32.5 28 L 42 28 L 42 10.5 C 42 8.0324991 39.967501 6 37.5 6 L 10.5 6 z M 33 31 C 31.895 31 31 31.895 31 33 L 31 41.119141 L 41.119141 31 L 33 31 z" />
                <TextBox x:Name="ItemName" Margin="5,0,0,0" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Text="{Binding Path=Name}"/>
            </StackPanel>

        </HierarchicalDataTemplate>

        <!-- ItemProjectTreeLine -->
        <HierarchicalDataTemplate DataType="{x:Type local:ItemProjectTreeLine}" ItemsSource="{Binding Children}" >

            <StackPanel Orientation="Horizontal" Background="Transparent" Margin="1" Height="16" >
                <Path x:Name="Icon" Stroke="Transparent" Fill="#FF808080" Height="14" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center"  VerticalAlignment="Center"  Data="M 25.980469 2.9902344 A 1.0001 1.0001 0 0 0 25.292969 3.2929688 L 3.2929688 25.292969 A 1.0001 1.0001 0 1 0 4.7070312 26.707031 L 26.707031 4.7070312 A 1.0001 1.0001 0 0 0 25.980469 2.9902344 z" />
                <TextBox x:Name="ItemName" Margin="5,0,0,0" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Text="{Binding Path=Name}"/>
                <TextBox x:Name="ItemPoints" Margin="5,0,0,0" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Text="{Binding Path=Points}"/>
            </StackPanel>

        </HierarchicalDataTemplate>

        <!-- ItemProjectTreeLoopSystem -->
        <HierarchicalDataTemplate DataType="{x:Type local:ItemProjectTreeLoopSystem}" ItemsSource="{Binding Children}" >

            <StackPanel Orientation="Horizontal" Background="Transparent" Margin="1" Height="16" >
                <Path x:Name="Icon" Stroke="Transparent" Fill="Orange" Height="14" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center"  VerticalAlignment="Center"  Data="M 8.5 8 C 6.019 8 4 10.019 4 12.5 L 4 18 L 16.052734 18 C 16.636734 18 17.202344 17.793922 17.652344 17.419922 L 23.5 12.546875 L 19.572266 9.2734375 C 18.586266 8.4524375 17.336734 8 16.052734 8 L 8.5 8 z M 27.644531 13 L 19.572266 19.724609 C 18.585266 20.546609 17.336734 21 16.052734 21 L 4 21 L 4 35.5 C 4 37.981 6.019 40 8.5 40 L 39.5 40 C 41.981 40 44 37.981 44 35.5 L 44 17.5 C 44 15.019 41.981 13 39.5 13 L 27.644531 13 z" />
                <TextBox x:Name="ItemName" Margin="5,0,0,0" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Text="{Binding Path=Name}"/>
                <TextBox x:Name="ItemFunctionGroup" Margin="5,0,0,0" Foreground="Green" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Bold" FontSize="12"  Text="{Binding Path=FunctionGroup}"/>
            </StackPanel>

        </HierarchicalDataTemplate>

        <!-- ItemProjectTreeLoopPage -->
        <HierarchicalDataTemplate DataType="{x:Type local:ItemProjectTreeLoopPage}" ItemsSource="{Binding Children}" >

            <StackPanel Orientation="Horizontal" Background="Transparent" Margin="1" Height="16" >
                <Path x:Name="Icon" Stroke="Transparent" Fill="Orange" Height="14" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center"  VerticalAlignment="Center"  Data="M10.9,6.2c-2.6,0-4.7,2.1-4.7,4.7v28.1c0,2.6,2.1,4.7,4.7,4.7h18.2v-9.9c0-2.6,2.1-4.7,4.7-4.7h9.9V10.9c0-2.6-2.1-4.7-4.7-4.7H10.9ZM34.4,32.3c-1.2,0-2.1.9-2.1,2.1v8.5l10.5-10.5h-8.5ZM18.9,9.3c.6,0,1.1.4,1.3,1.1l1.4,4.6h4.9c1.3.2,1.8,2,.6,2.9l-3.8,2.9,1.4,4.6v.2c.3,1.3-1.2,2.4-2.3,1.5l-3.8-2.9-3.8,2.9h-.2c-1.2.8-2.6-.4-2.1-1.8l1.4-4.6-3.8-2.9-.2-.2c-.9-1-.3-2.7,1.1-2.7h4.7s1.4-4.6,1.4-4.6v-.3c.4-.6,1-.9,1.6-.8Z" />
                <TextBox x:Name="ItemName" Margin="5,0,0,0" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Text="{Binding Path=Name}"/>
            </StackPanel>

        </HierarchicalDataTemplate>

        <!-- ItemProjectTreeLoopPumpe -->
        <HierarchicalDataTemplate DataType="{x:Type local:ItemProjectTreeLoopPumpe}" ItemsSource="{Binding Children}" >

            <StackPanel Orientation="Horizontal" Background="Transparent" Margin="1" Height="16" >
                <Path x:Name="Icon" Stroke="Transparent" Fill="Orange" Height="14" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center"  VerticalAlignment="Center"  Data="M 6 3 A 1.0001 1.0001 0 1 0 6 5 L 6 8 L 10 8 L 10 5 A 1.0001 1.0001 0 1 0 10 3 L 6 3 z M 16.828125 7 C 16.298125 7 15.789062 7.2109375 15.414062 7.5859375 L 13 10 L 13 22 L 15.414062 24.414062 C 15.789062 24.789062 16.298125 25 16.828125 25 L 28 25 C 29.105 25 30 24.105 30 23 L 30 9 C 30 7.895 29.105 7 28 7 L 16.828125 7 z M 19 9 L 27 9 C 27.553 9 28 9.447 28 10 L 28 22 C 28 22.553 27.553 23 27 23 L 19 23 C 18.447 23 18 22.553 18 22 C 18 21.447 18.447 21 19 21 L 26 21 L 26 19 L 19 19 C 18.447 19 18 18.553 18 18 C 18 17.447 18.447 17 19 17 L 26 17 L 26 15 L 19 15 C 18.447 15 18 14.553 18 14 C 18 13.447 18.447 13 19 13 L 26 13 L 26 11 L 19 11 C 18.447 11 18 10.553 18 10 C 18 9.447 18.447 9 19 9 z M 6 10 C 4.895 10 4 10.895 4 12 L 4 13 L 2 13 A 1.0001 1.0001 0 0 0 0.984375 11.986328 A 1.0001 1.0001 0 0 0 0 13 L 0 19 A 1.0001 1.0001 0 1 0 2 19 L 4 19 L 4 20 C 4 21.105 4.895 22 6 22 L 11 22 L 11 10 L 6 10 z" />
                <TextBox x:Name="ItemName" Margin="5,0,0,0" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Text="{Binding Path=Name}"/>
            </StackPanel>

        </HierarchicalDataTemplate>

        <!-- ItemProjectTreeLoopVentil -->
        <HierarchicalDataTemplate DataType="{x:Type local:ItemProjectTreeLoopVentil}" ItemsSource="{Binding Children}" >

            <StackPanel Orientation="Horizontal" Background="Transparent" Margin="1" Height="16" >
                <Path x:Name="Icon" Stroke="Transparent" Fill="Orange" Height="14" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center"  VerticalAlignment="Center"  Data="M 6 3 A 1.0001 1.0001 0 1 0 6 5 L 6 8 L 10 8 L 10 5 A 1.0001 1.0001 0 1 0 10 3 L 6 3 z M 16.828125 7 C 16.298125 7 15.789062 7.2109375 15.414062 7.5859375 L 13 10 L 13 22 L 15.414062 24.414062 C 15.789062 24.789062 16.298125 25 16.828125 25 L 28 25 C 29.105 25 30 24.105 30 23 L 30 9 C 30 7.895 29.105 7 28 7 L 16.828125 7 z M 19 9 L 27 9 C 27.553 9 28 9.447 28 10 L 28 22 C 28 22.553 27.553 23 27 23 L 19 23 C 18.447 23 18 22.553 18 22 C 18 21.447 18.447 21 19 21 L 26 21 L 26 19 L 19 19 C 18.447 19 18 18.553 18 18 C 18 17.447 18.447 17 19 17 L 26 17 L 26 15 L 19 15 C 18.447 15 18 14.553 18 14 C 18 13.447 18.447 13 19 13 L 26 13 L 26 11 L 19 11 C 18.447 11 18 10.553 18 10 C 18 9.447 18.447 9 19 9 z M 6 10 C 4.895 10 4 10.895 4 12 L 4 13 L 2 13 A 1.0001 1.0001 0 0 0 0.984375 11.986328 A 1.0001 1.0001 0 0 0 0 13 L 0 19 A 1.0001 1.0001 0 1 0 2 19 L 4 19 L 4 20 C 4 21.105 4.895 22 6 22 L 11 22 L 11 10 L 6 10 z" />
                <TextBox x:Name="ItemName" Margin="5,0,0,0" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Text="{Binding Path=Name}"/>
            </StackPanel>

        </HierarchicalDataTemplate>

        <!-- ItemProjectTreeLoopFühler -->
        <HierarchicalDataTemplate DataType="{x:Type local:ItemProjectTreeLoopFühler}" ItemsSource="{Binding Children}" >

            <StackPanel Orientation="Horizontal" Background="Transparent" Margin="1" Height="16" >
                <Path x:Name="Icon" Stroke="Transparent" Fill="Orange" Height="14" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center"  VerticalAlignment="Center"  Data="M 6 3 A 1.0001 1.0001 0 1 0 6 5 L 6 8 L 10 8 L 10 5 A 1.0001 1.0001 0 1 0 10 3 L 6 3 z M 16.828125 7 C 16.298125 7 15.789062 7.2109375 15.414062 7.5859375 L 13 10 L 13 22 L 15.414062 24.414062 C 15.789062 24.789062 16.298125 25 16.828125 25 L 28 25 C 29.105 25 30 24.105 30 23 L 30 9 C 30 7.895 29.105 7 28 7 L 16.828125 7 z M 19 9 L 27 9 C 27.553 9 28 9.447 28 10 L 28 22 C 28 22.553 27.553 23 27 23 L 19 23 C 18.447 23 18 22.553 18 22 C 18 21.447 18.447 21 19 21 L 26 21 L 26 19 L 19 19 C 18.447 19 18 18.553 18 18 C 18 17.447 18.447 17 19 17 L 26 17 L 26 15 L 19 15 C 18.447 15 18 14.553 18 14 C 18 13.447 18.447 13 19 13 L 26 13 L 26 11 L 19 11 C 18.447 11 18 10.553 18 10 C 18 9.447 18.447 9 19 9 z M 6 10 C 4.895 10 4 10.895 4 12 L 4 13 L 2 13 A 1.0001 1.0001 0 0 0 0.984375 11.986328 A 1.0001 1.0001 0 0 0 0 13 L 0 19 A 1.0001 1.0001 0 1 0 2 19 L 4 19 L 4 20 C 4 21.105 4.895 22 6 22 L 11 22 L 11 10 L 6 10 z" />
                <TextBox x:Name="ItemName" Margin="5,0,0,0" BorderThickness="0" Padding="0" VerticalAlignment="Center" FontWeight="Normal" FontSize="12"  Text="{Binding Path=Name}"/>
            </StackPanel>

        </HierarchicalDataTemplate>

    </Page.Resources>
</Page>
